Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain operator should respect array constructor #714

Conversation

netomi
Copy link
Contributor

@netomi netomi commented Sep 23, 2024

This PR fixes the problem where when using a HOF like map with a chain operator, the array constructor is not respected which is added to enforce that the output is always an array regardless of the input.

Take this example:

$map([1], function($v){$v*$v})[]

returns correctly [1]. However, when using a chain operator like that:

$ ~> $map(function($v){$v*$v})[]

and providing [1] as input, the singleton value is returned.
This PR fixes that and adds 2 test cases to the test suite.

Copy link
Member

@mattbaileyuk mattbaileyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fix!

@mattbaileyuk mattbaileyuk merged commit 9e6b8e6 into jsonata-js:master Sep 27, 2024
7 checks passed
@netomi netomi deleted the fix-chain-opeator-to-respect-array-constructor branch September 27, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants